package nk.backtack;

//AB26 汉诺塔问题


import java.util.ArrayList;
import java.util.Arrays;

public class AB26 {
    ArrayList<String> list = new ArrayList<>();

    public ArrayList<String> getSolution (int n) {
        hanno(n, "left", "mid", "right");
        return list;
    }
    private void hanno(int n, String left, String mid, String right) {
        if (n == 1) {
            list.add("move from " + left + " to " + right);
            return;
        }
        hanno(n - 1, left, right, mid);
        list.add("move from " + left + " to " + right);
        hanno(n - 1, mid, left, right);
    }

}
